package com.aloda.mapper;


import com.aloda.dto.EmployeePageDTO;
import com.aloda.entity.Employee;
import com.aloda.vo.EmployeePageVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmpMapper {


    /**
     * 员工登录
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getEmpByUsername(String username);

    /**
     * 通过员工id获取员工
     * @param tureId
     * @return
     */
    @Select("select * from employee where id = #{tureId}")
    Employee getEmpById(Long tureId);

    /**
     * 更新员工信息
     * @param employee
     */
    void updateEmpInfo(Employee employee);

    /**
     * 员工分页查询
     * @param employeePageDTO
     * @return
     */
    Page<EmployeePageVO> page(EmployeePageDTO employeePageDTO);

    /**
     * 根据id查找用户名
     * @param currentId
     * @return
     */
    @Select("select username from employee where id = #{currentId}")
    String getEmpUsernameById(Long currentId);

    /**
     * 插入员工数据
     * @param employee
     */
    @Insert("insert into employee(name, username, password, phone, sex, id_number, create_time, update_time, create_user, update_user,status,authority,avatar_url)" +
            "values" +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status},#{authority},#{avatarUrl})")
    void insert(Employee employee);
}
